import Vue from 'vue';
import VueRouter from 'vue-router';

Vue.use(VueRouter);

// 解决ElementUI导航栏中的vue-router在3.0版本以上重复点菜单报错问题
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}

export default new VueRouter({
    saveScrollPosition: true,
    routes: [
        {
            name: 'index',
            path: '/index',
            component: resolve => require(['../pages/index/Index.vue'], resolve),
            meta: {
                title: 'menu.index',
            }
        },
        {
            name: 'stats',
            path: '/stats',
            component: resolve => require(['../pages/stats/Index.vue'], resolve),
            meta: {
                title: 'menu.stats',
            }
        },
        {
            name: 'stats.summary',
            path: '/stats/summary',
            component: resolve => require(['../pages/stats/summary/Index.vue'], resolve),
            meta: {
                title: 'menu.stats.summary',
            }
        },
        {
            name: 'stats.user.player',
            path: '/stats/user/player',
            component: resolve => require(['../pages/stats/user/player/Index.vue'], resolve),
            meta: {
                title: 'menu.stats.user.player',
            }
        },
        {
            name: 'stats.user.retention',
            path: '/stats/user/retention',
            component: resolve => require(['../pages/stats/user/retention/Index.vue'], resolve),
            meta: {
                title: 'menu.stats.user.retention',
            }
        },
        {
            name: 'stats.user.player-bet',
            path: '/stats/user/player-bet',
            component: resolve => require(['../pages/stats/user/player-bet/Index.vue'], resolve),
            meta: {
                title: 'menu.stats.user.player-bet',
            }
        },
        {
            name: 'stats.game.game',
            path: '/stats/game/game',
            component: resolve => require(['../pages/stats/game/game/Index.vue'], resolve),
            meta: {
                title: 'menu.stats.game.game',
            }
        },
        {
            name: 'stats.game.best',
            path: '/stats/game/best',
            component: resolve => require(['../pages/stats/game/best/Index.vue'], resolve),
            meta: {
                title: 'menu.stats.game.best',
            }
        },
        {
            name: 'stats.platform.settlement',
            path: '/stats/platform/settlement',
            component: resolve => require(['../pages/stats/platform/settlement/Index.vue'], resolve),
            meta: {
                title: 'menu.stats.platform.settlement',
            }
        },
        {
            name: 'stats.platform.best',
            path: '/stats/platform/best',
            component: resolve => require(['../pages/stats/platform/best/Index.vue'], resolve),
            meta: {
                title: 'menu.stats.platform.best',
            }
        },
        {
            name: 'platform.setting',
            path: '/platform/setting',
            component: resolve => require(['../pages/platform/setting/Index.vue'], resolve),
            meta: {
                title: 'menu.platform.setting',
            }
        },
        {
            name: 'platform.user',
            path: '/platform/user',
            component: resolve => require(['../pages/platform/user/Index.vue'], resolve),
            meta: {
                title: 'menu.platform.user',
            }
        },
        {
            name: 'platform.settlement',
            path: '/platform/settlement',
            component: resolve => require(['../pages/platform/settlement/Index.vue'], resolve),
            meta: {
                title: 'menu.platform.settlement',
            }
        },
        {
            name: 'platform.doc',
            path: '/platform/doc',
            component: resolve => require(['../pages/platform/doc/Index.vue'], resolve),
            meta: {
                title: 'menu.platform.doc',
            }
        },
        {
            name: 'game.user',
            path: '/game/user',
            component: resolve => require(['../pages/game/user/Index.vue'], resolve),
            meta: {
                title: 'menu.game.user',
            }
        },
        {
            name: 'game.data.settlement',
            path: '/game/data/settlement',
            component: resolve => require(['../pages/game/data/settlement/Index.vue'], resolve),
            meta: {
                title: 'menu.game.data.settlement',
            }
        },
        {
            name: 'game.data.log-cost',
            path: '/game/data/log-cost',
            component: resolve => require(['../pages/game/data/log-cost/Index.vue'], resolve),
            meta: {
                title: 'menu.game.data.log-cost',
            }
        },
        {
            name: 'game.data.log-login',
            path: '/game/data/log-login',
            component: resolve => require(['../pages/game/data/log-login/Index.vue'], resolve),
            meta: {
                title: 'menu.game.data.log-login',
            }
        },
        {
            name: 'pay.order.transfer',
            path: '/pay/order/transfer',
            component: resolve => require(['../pages/pay/order/transfer/Index.vue'], resolve),
            meta: {
                title: 'menu.pay.order.transfer',
            }
        },
        {
            name: 'pay.order.wallet',
            path: '/pay/order/wallet',
            component: resolve => require(['../pages/pay/order/wallet/Index.vue'], resolve),
            meta: {
                title: 'menu.pay.order.wallet',
            }
        },
        {
            name: 'system.setting.language',
            path: '/system/setting/language',
            component: resolve => require(['../pages/system/setting/language/Index.vue'], resolve),
            meta: {
                title: 'menu.system.setting.language',
            }
        },
        {
            name: 'system.setting.server',
            path: '/system/setting/server',
            component: resolve => require(['../pages/system/setting/server/Index.vue'], resolve),
            meta: {
                title: 'menu.system.setting.server',
            }
        },
        {
            name: 'system.setting.menu',
            path: '/system/setting/menu',
            component: resolve => require(['../pages/system/setting/menu/Index.vue'], resolve),
            meta: {
                title: 'menu.system.setting.menu',
            }
        },
        {
            name: 'system.user',
            path: '/system/user',
            component: resolve => require(['../pages/system/user/Index.vue'], resolve),
            meta: {
                title: 'menu.system.user',
            }
        },
        {
            name: 'system.permission',
            path: '/system/permission',
            component: resolve => require(['../pages/system/permission/Index.vue'], resolve),
            meta: {
                title: 'menu.system.permission',
            }
        },
        {
            name: 'system.log.activity',
            path: '/system/log/activity',
            component: resolve => require(['../pages/system/log/activity/Index.vue'], resolve),
            meta: {
                title: 'menu.system.log.activity',
            }
        },
        {
            name: 'system.log.login',
            path: '/system/log/login',
            component: resolve => require(['../pages/system/log/login/Index.vue'], resolve),
            meta: {
                title: 'menu.system.log.login',
            }
        },
        {
            name: 'home',
            path: '/home',
            component: resolve => require(['../pages/home/Index.vue'], resolve),
            meta: {
                title: 'home.title',
                hasPermissionExcept: true,
            }
        },
        {
            name: 'error.403',
            path: '/error/403',
            component: require('../pages/errors/403.vue').default,
            meta: {
                title: 'error.403',
                hasPermissionExcept: true,
            }
        },
        {
            name: 'error.404',
            path: '/error/404',
            component: require('../pages/errors/404.vue').default,
            meta: {
                title: 'error.404',
                hasPermissionExcept: true,
            }
        },
        {
            path: "*",
            component: require('../pages/Index.vue').default
        }
    ]
});
